<template>
	<div class="goods-container">
		<router-link class="item" v-for='(item,index) in goodslist' :key='index' :to="'/home/goodsinfo/'+index">
			<div class="top">
				<img :src="item.img" />
				<p>{{ item.title }}</p>
			</div>
			<div class="bottom">
				<span class="now">￥{{ item.now }}</span>
				<span class="prime">￥{{ item.prime }}</span>
				<div class="bottom-container">
					<span>热卖中</span>
					<span>剩{{ item.num }}件</span>
				</div>
			</div>
		</router-link>
	</div>
</template>

<script>
	import mui from '../../lib/mui/js/mui.min.js'

	export default {
		data() {
			return {
				goodslist: [],
			}
		},
		created() {
			this.getGoods();
		},
		methods: {
			getGoods() {
				this.$http.get('data.php').then(result => {
					if(result.body.status == true) {
						this.goodslist = result.body.goods;
						console.log(this.list.img)
					} else {
						Toast('获取商品列表信息失败...');
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goods-container {
		/*display: flex;
		flex-direction: row;
		justify-content: space-around;*/
		.item {
			width: 48%;
			margin-top: 10px;
			box-shadow: 0 0 3px #ccc;
			border: 4px solid #fff;
			background: #fff;
			position:relative;
			height:275px;
			float:left;
			margin-left: 5px;
			img {
				width: 100%;
				height: 170px;
			}
			p {
				padding: 0 5px;
				color: #000;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				font-size: 12px;
				font-weight: bold;
			}
			.bottom{
				width: 100%;
				height: 50px;
				background: rgb(238,238,238);
				position: absolute;
				bottom: 0px;
				border: none;
				.now{
					font-size: 14px;
					color: red;
					padding-left: 7px;
				}
				.prime{
					font-size: 11px;
					text-decoration: line-through;
					margin-left: 15px;
					color: rgb(143,143,148);
				}
			.bottom-container{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				font-size: 12px;
				color: rgb(143,143,148);
				margin-top: 5px;
				padding-left: 5px;
				padding-right: 5px;
			}	
			}
		}
	}
</style>